import { TDrama } from "../../../../../Message/Db/Tables/TDrama";
import { Global } from "../../../../../com/gengine/global/Global";
import { LayerManager } from "../../../manager/LayerManager";
import { TweenMax } from "../../../../../com/greensock/TweenMax";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
type int = number;
//class Lv70OpShowDrama
    
    export  class Lv70OpShowDrama
    {
        

        public dispose(): void
        {
            return;
        }

        public call(arg1: TDrama, arg2: Function=null): void
        {
            var config: TDrama;
            var callback: Function=null;
            var onEnd: Function;

            var loc1;
            onEnd = null;
            config = arg1;
            callback = arg2;
            onEnd = (): void
            {
                _isTweening = false;
                if (_shouldResizeAfterTweening) 
                {
                    _shouldResizeAfterTweening = false;
                    doResizeByStage();
                }
                if (callback != null) 
                {
                    callback.apply();
                }
                return;
            }
            if (this._isHide) 
            {
                if (callback != null) 
                {
                    callback.apply();
                }
                return;
            }
            this._isHide = true;
            this._isTweening = true;
            flash.utils.setTimeout(onEnd, this.PopupTime * 1000);
            this.top.y = -this.top.height;
            this.top.x = 0;
            this.bottom.y = Global.stage.stageHeight + this.bottom.height;
            this.bottom.x = Global.stage.stageWidth;
            LayerManager.highestLayer.addChild(this.top);
            LayerManager.highestLayer.addChild(this.bottom);
            TweenMax.to(this.top, this.PopupTime, {"y": 0});
            TweenMax.to(this.bottom, this.PopupTime, {"y": Global.stage.stageHeight});
            return;
        }

        public cancel(arg1: TDrama, arg2: Function=null): void
        {
            var config: TDrama;
            var callback: Function=null;
            var onEnd: Function;

            var loc1;
            onEnd = null;
            config = arg1;
            callback = arg2;
            onEnd = (): void
            {
                _isTweening = false;
                _isHide = false;
                if (_shouldResizeAfterTweening) 
                {
                    _shouldResizeAfterTweening = false;
                    doResizeByStage();
                }
                if (top.parent != null) 
                {
                    top.parent.removeChild(top);
                }
                if (bottom.parent != null) 
                {
                    bottom.parent.removeChild(bottom);
                }
                if (callback != null) 
                {
                    callback.apply();
                }
                return;
            }
            if (!this._isHide) 
            {
                if (callback != null) 
                {
                    callback.apply();
                }
                return;
            }
            this._isTweening = true;
            TweenMax.to(this.top, this.PopupTime, {"y":-this.top.height});
            TweenMax.to(this.bottom, this.PopupTime, {"y": Global.stage.stageHeight + this.bottom.height, "onComplete": onEnd});
            return;
        }

        public doResizeByStage(): void
        {
            if (this._isTweening) 
            {
                this._shouldResizeAfterTweening = true;
                return;
            }
            this.top.graphics.clear();
            this.resizeTop();
            this.bottom.graphics.clear();
            this.resizeBottom();
            if (this._isHide) 
            {
                this.top.y = 0;
                this.bottom.y = Global.stage.stageHeight;
            }
            else 
            {
                this.top.y = -this.top.height;
                this.bottom.y = Global.stage.stageHeight + this.bottom.height;
            }
            return;
        }

        /* internal  */get top(): Object /* flash.display.Sprite */
        {
            if (this._top == null) 
            {
                this._topShadow = GlobalClass.getBitmap(ImagesConst.Lv70DramaBlackShadow);
                this._top = new Object /* flash.display.Sprite */();
                this._top.addChild(this._topShadow);
                this.resizeTop();
            }
            return this._top;
        }

        /* internal  */get bottom(): Object /* flash.display.Sprite */
        {
            if (this._bottom == null) 
            {
                this._bottomShadow = GlobalClass.getBitmap(ImagesConst.Lv70DramaBlackShadow);
                this._bottom = new Object /* flash.display.Sprite */();
                this._bottom.addChild(this._bottomShadow);
                this.resizeBottom();
            }
            return this._bottom;
        }

        /* internal  */resizeBottom(): void
        {
            this._bottom.graphics.beginFill(0, 0.8);
            this._bottom.graphics.drawRect(0, 0, Global.stage.stageWidth, this.BlackHeight);
            this._bottom.graphics.endFill();
            this._bottomShadow.x = 0;
            this._bottomShadow.y = this.BlackHeight;
            this._bottomShadow.width = Global.stage.stageWidth;
            this._bottom.rotation = 180;
            this._bottom.x = Global.stage.stageWidth;
            return;
        }

        /* internal  */resizeTop(): void
        {
            this._top.graphics.beginFill(0, 0.8);
            this._top.graphics.drawRect(0, 0, Global.stage.stageWidth, this.BlackHeight);
            this._top.graphics.endFill();
            this._topShadow.x = 0;
            this._topShadow.width = Global.stage.stageWidth;
            this._topShadow.y = this.BlackHeight;
            return;
        }

        /* internal */ /* const */BlackHeight: int=80;

        /* internal */ /* const */PopupTime: number=0.6;

        /* internal */ /* var */_top: Object /* flash.display.Sprite */;

        /* internal */ /* var */_topShadow: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bottom: Object /* flash.display.Sprite */;

        /* internal */ /* var */_bottomShadow: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isHide: Boolean=false;

        /* internal */ /* var */_isTweening: Boolean=false;

        /* internal */ /* var */_shouldResizeAfterTweening: Boolean=false;
    }
